﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace gt.UserInfo.DomainModels.Respository
{
    public class DataPager<TEntity>
    {
        /// <summary>
        /// Represents the total record count for the query
        /// </summary>
        public int TotalResult
        {
            get;
            set;
        }

        /// <summary>
        /// Represents the total pages 
        /// </summary>
        public int TotalPages
        {
            get
            {
                return (TotalResult + PageSize - 1) / PageSize;

            }
        }

        public int StartIndex
        {
            get
            {
                return (PageIndex - 1) * PageSize + 1;
            }
        }

        public int EndIndex
        {
            get
            {
                return PageIndex * PageSize;
            }
        }

        /// <summary>
        /// Represents the page size
        /// </summary>
        public int PageSize
        {
            get;
            set;
        }

        /// <summary>
        /// Represents the page index ,starting with 1 as first page
        /// </summary>
        public int PageIndex
        {
            get;
            set;
        }

        /// <summary>
        /// Represents the data list for specified page index and page size
        /// </summary>
        public IList<TEntity> Data
        {
            get;
            set;
        }

    }
}
